﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="<{$ipath}>alipay/css/layout.css">
    <link rel="stylesheet" href="<{$ipath}>alipay/css/base.css">
    <link rel="stylesheet" href="<{$ipath}>alipay/css/reply.css">
    <script type="text/javascript" src="<{$ipath}>alipay/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="<{$ipath}>alipay/js/_base.js"></script>
    <title>自动回复</title>

</head>
<body>
<div class="auto_reply">
    <div class="reply_tab_wrap">
        <ul class="auto_reply_tab">
            <li class="actived"><a href="?g=alipay&amp;m=autoreply&amp;a=index">消息自动回复</a></li>
            <li><a href="?g=alipay&amp;m=keyreply&amp;a=index">关键词自动回复</a></li>
        </ul>
    </div>
    <div class="reply_header_tip"><a href="<{$basehost}>api/help_detail.php">如何设置消息自动回复？</a></div>
    <div class="reply_edit_wrap">
        <div class="message-edit-cont">
            <div class="message-edit-type fn-clear">
                <a class="message-edit message-edit-text fn-left <{if $retype neq 1}>active<{/if}>" >文字</a>
                <div class="message-edit-message fn-left">
                    <a class="message-edit message-edit-hybrid fn-left <{if $retype eq 1}>active<{/if}>" >图文广播</a>
                    <ul class="message-hibrid-menu" style="display: none;">
                        <li><a href="?g=alipay&m=fodder&a=single" class="message-single-message">新建单图文广播</a></li>
                        <li><a href="?g=alipay&m=fodder&a=multi" class="message-multi-message">新建多图文广播</a></li>
                        <li><a  class="message-page-store">从素材库中选取</a></li>
                    </ul>
                </div>
            </div>

            <{if $info}>
                <{if $retype eq 1}>
                    <div class="message-edit-area fn-hide fn-clear clearfix" >
                        <textarea name="content"  maxlength="600" class="message-text-area fn-left"  ></textarea>
                        <div class="message-edit-stat fn-left">
                            <span class="message-rest-num fn-right">还可以输入<span class="restNum">600</span>字</span>
                        </div>
                    </div>

                    <div class="message-contain clearfix">
                        <div class="message-list fl" msgid="">
                            <div class="message-item">
                                <div class="message-body">
                                    <{foreach $info as $kk => $vv}>
                                    <{if $kk eq 0}>
                                    <a href="" class="item-url">
                                        <div class="message-title first-message-title"><div class="title-wrapper"><h4 class="popTit"><{$vv.title}></h4><div class="title-bg"></div></div></div>
                                        <{if $msgnum eq 1}>
                                        <div class="message-info"><{$vv.time}></div>
                                        <{/if}>
                                        <div class="message-cover-pic">
                                            <img src="<{$vv.img_url}>" class="cover" >
                                        </div>
                                        <{if $msgnum eq 1}>
                                        <div class="message-text word-bread"><{$vv.abstract}></div>
                                        <span class="view">立即查看</span>
                                        <{/if}>
                                    </a>
                                    <{else}>
                                    <a href="" class="item-url">
                                        <ul class="show-cont ui-sortable">
                                            <li  class="show-item fn-clear">
                                                <div class="cover-pic J_change_image" data-image="image" data-default="缩略图">
                                                    <img src="<{$vv.img_url}>" class="slImg">
                                                </div>
                                                <h1 class="show-title title-break J_change_title" data-title="title" data-default="标题">
                                                    <{$vv.title}>
                                                </h1>
                                            </li>
                                        </ul>
                                    </a>
                                    <{/if}>
                                    <{/foreach}>
                                </div>

                            </div>
                        </div>
                    </div>
                <{else}>
                    <div class="message-edit-area  fn-clear clearfix" >
                        <textarea name="content"  maxlength="600" class="message-text-area fn-left"  ><{$info.content}></textarea>
                        <div class="message-edit-stat fn-left">
                            <span class="message-rest-num fn-right">还可以输入<span class="restNum">600</span>字</span>
                        </div>
                    </div>
                    <div class="message-contain fn-hide clearfix">
                    </div>
                <{/if}>
            <{else}>
            <div class="message-edit-area  fn-clear clearfix" >
                    <textarea name="content"  maxlength="600" class="message-text-area fn-left"  ></textarea>
                    <div class="message-edit-stat fn-left">
                        <span class="message-rest-num fn-right">还可以输入<span class="restNum">600</span>字</span>
                    </div>
                </div>

                <div class="message-contain fn-hide clearfix">
                </div>
            <{/if}>
            <div class="form-validate-tip fn-clear">
                <div class="form-explain send-message-empty fn-left fn-hide">请填写/选取内容</div>
            </div>
        </div>
    </div>
    <div class="action_wrap">
        <input type="hidden" value="0" id="edittype" />
        <input type="hidden" value="0" id="msgid" />
        <input type="button" value="保存" class="save_btn btn btn_orange" />
        <input type="button" value="删除" class="del_btn btn btn_gray" />
    </div>

</div>


<!-- popup -->
<div class="ui-mask"></div>
<div class="alipay-xbox" style="top: 210.5px; left: 124px; opacity: 1; z-index: 999;display:none;">
    <a class="close" title="关闭本框"  onclick="closediv('.alipay-xbox', '.ui-mask');" >×</a>
    <div class="alipay-xbox-content">
        <div class="message-box">
            <div class="title"><h3>选择图文广播</h3></div>
            <div class="top-tools fn-clear">
                <div class="fl">
                    <a href="?g=alipay&amp;m=fodder&amp;a=single" class="edit-single-message">新建单图文广播</a>
                    <a href="?g=alipay&amp;m=fodder&amp;a=multi" class="edit-multi-message">新建多图文广播</a>
                </div>
            </div>
            <div class="message-placeholder fn-clear">

                <{foreach $fodder as $k => $v}>
                <div class="message-list fl" msgid="<{$k}>">
                    <div class="message-item">
                        <div class="message-body">
                            <{foreach $v as $kk => $vv}>
                            <{if $kk eq 0}>
                            <a href="" class="item-url">
                                <div class="message-title first-message-title"><div class="title-wrapper"><h4 class="popTit"><{$vv.title}></h4><div class="title-bg"></div></div></div>
                                <{if $vv.type eq 1}>
                                <div class="message-info"><{$vv.time}></div>
                                <{/if}>
                                <div class="message-cover-pic">
                                    <img src="<{$vv.img_url}>" class="cover">
                                </div>
                                <{if $vv.type eq 1}>
                                <div class="message-text word-bread"><{$vv.abstract}></div>
                                <span class="view">立即查看</span>
                                <{/if}>
                            </a>
                            <{else}>
                            <a href="" class="item-url">
                                <ul class="show-cont ui-sortable">
                                    <li  class="show-item fn-clear">
                                        <div class="cover-pic J_change_image" data-image="image" data-default="缩略图">
                                            <img src="<{$vv.img_url}>" class="slImg">
                                        </div>
                                        <h1 class="show-title title-break J_change_title" data-title="title" data-default="标题">
                                            <{$vv.title}>
                                        </h1>
                                    </li>
                                </ul>
                            </a>
                            <{/if}>
                            <{/foreach}>
                        </div>
                        <div class="message-filter"></div>
                        <div class="chosen"></div>
                    </div>
                </div>
                <{/foreach}>
            </div>
            <div class="actions">
                <a class="submit"><span class="btn btn-orange">确&nbsp;&nbsp;定</span></a>
                <a class="cancel"><span class="btn btn-gray" onclick="closediv('.alipay-xbox','.ui-mask');">取&nbsp;&nbsp;消</span></a>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        //文字输入字数显示
        $(".message-edit-cont .message-edit-area .message-text-area").keyup(function () {
            var len = $(this).val().length;
            if (len > 0) {
                $('.message-edit-cont .form-validate-tip').hide();
            }
            var restNum = $(".message-edit-cont .message-edit-area .message-text-area").attr("maxlength") - len;
            $('.message-edit-cont .message-edit-stat .restNum').text(restNum);

        });
        //文字类型切换
        $(".message-edit-type .message-edit-text").click(function () {
            $("#edittype").val("0");
            $("#msgid").val("0");
            if (!$(".message-edit-cont .message-edit-type .message-edit-text").hasClass("active")) {
                $(".message-edit-cont .message-edit-area .message-text-area").val("");
                $('.message-edit-cont .message-edit-stat .restNum').text($(".message-edit-cont .message-edit-area .message-text-area").attr("maxlength"));
            }
            $(".message-edit-cont .message-edit-type .message-edit-hybrid").removeClass("active");
            $(".message-edit-cont .message-edit-type .message-edit-text").addClass("active");
            $(".message-edit-cont .message-contain").empty();
            $(".message-edit-cont .message-edit-area").show();
            $(".message-edit-cont .message-contain").hide();

        });
        //图文广告播下拉
        $(".message-edit-message").hover(function () {
            $(this).find(".message-hibrid-menu").show();
        }, function () {
            $(this).find(".message-hibrid-menu").hide();
        });

        //素材框
        $(".message-page-store").click(function(){
            showdiv('.alipay-xbox');
            $(".alipay-xbox .active").removeClass("active");
        });
        $(".alipay-xbox .message-list").click(function () {
            $(this).addClass("active");
            $(this).siblings(".message-list").removeClass("active");
            $(".alipay-xbox").attr("msgid", $(this).attr("msgid"));
        });
        //确定选取
        $(".alipay-xbox .actions .submit").click(function () {
            $("#edittype").val("1");
            $(".message-edit-cont .message-edit-type .message-edit-hybrid").addClass("active");
            $(".message-edit-cont .message-edit-type .message-edit-text").removeClass("active");
            closediv('.alipay-xbox', '.ui-mask');
            var messageContain = $(".message-edit-cont .message-contain");
            messageContain.show();
            messageContain.empty();
            var messageEditArea = $(".message-edit-cont .message-edit-area");
            messageEditArea.hide();
            var selectedMessage = $(".message-list.active").clone();
            selectedMessage.removeClass("active");
            selectedMessage.find(".message-filter").remove();
            selectedMessage.find(".chosen").remove();
            messageContain.append(selectedMessage);
            $(".message-edit-cont .message-edit-area .message-text-area").val("");
            $("#msgid").val($(".alipay-xbox").attr("msgid"));
        });

        $(".action_wrap .save_btn").click(function () {
            var textArea = $(".message-edit-cont .message-edit-area .message-text-area");
            var edittype=$("#edittype").val();
            var content="";
            if (edittype == "0" && $.trim(textArea.val())=="") {

                $('.message-edit-cont .form-validate-tip').show();
                return;
            } else if (edittype == "1" && ($.trim($("#msgid").val())=="0"|| $.trim($("#msgid").val())=="")) {
                $('.message-edit-cont .form-validate-tip').show();
                return;
            }
            if(edittype=="0"){
                content = textArea.val();
            }
            else {
                content = $("#msgid").val();

            }
            var url = "?g=alipay&m=autoreply&a=msgedit";
            //ajax操作
            $.post(url, {content: content, type: edittype}, function(data){
                if(data.status)
                {
                    alert('保存成功');
                }
            }, 'json');

        });
        $(".action_wrap .del_btn").click(function () {
            //ajax操作
            var url = "?g=alipay&m=autoreply&a=msgdel";
            //ajax操作
            $.post(url, {}, function(data){
                if(data.status)
                {
                    //成功后调用
                    window.location.reload();
                }
            }, 'json');

        });
    });
</script>


</body>
</html>